package edu.unlv.cs.ladders.entities;

import java.lang.Boolean;
import java.lang.SuppressWarnings;
import java.util.Calendar;
import javax.persistence.EntityManager;
import javax.persistence.Query;

privileged aspect Tournament_Roo_Finder {
    
    @SuppressWarnings("unchecked")
    public static Query Tournament.findTournamentsByClosed(Boolean closed) {
        if (closed == null) throw new IllegalArgumentException("The closed argument is required");
        EntityManager em = Tournament.entityManager();
        Query q = em.createQuery("SELECT Tournament FROM Tournament AS tournament WHERE tournament.closed = :closed");
        q.setParameter("closed", closed);
        return q;
    }
    
    @SuppressWarnings("unchecked")
    public static Query Tournament.findTournamentsByClosedAndEndDateLessThan(Boolean closed, Calendar endDate) {
        if (closed == null) throw new IllegalArgumentException("The closed argument is required");
        if (endDate == null) throw new IllegalArgumentException("The endDate argument is required");
        EntityManager em = Tournament.entityManager();
        Query q = em.createQuery("SELECT Tournament FROM Tournament AS tournament WHERE tournament.closed = :closed AND tournament.endDate < :endDate");
        q.setParameter("closed", closed);
        q.setParameter("endDate", endDate);
        return q;
    }
    
}
